import { Component, OnInit } from '@angular/core';
import { Singlepage } from '../../model/singlepage';
import { Router} from '@angular/router';
import { SinglepageService } from '../../service/singlepage.service';

@Component({
  selector: 'app-singlepagelist',
  templateUrl: './singlepagelist.component.html',
  styleUrls: ['./singlepagelist.component.css']
})
export class SinglepagelistComponent implements OnInit {
  sl:Array<Singlepage>;
  constructor(
    private router:Router,
    private singlepageservice:SinglepageService
  ) { 
    this.sl=new Array();
    // for(let i=0;i<3;i++){
    //   let s=new Singlepage();
    //     s.singlepageid="id"+i;
    //     s.img   ="" ;
    //     s.summary="摘要"+i;
    //     s.title="标题"+i;
    //     s.detail="正文内容"+i;
    // this.sl.push(s);
    // }

  }

  ngOnInit() {
    this.sl=new Array();
    this.singlepageservice.getSinglepageList().then((data:any)=>{
      this.sl=data;
      console.log(this.sl[0].img);
    })
  }


// lookSinglepage(){
//   this.router.navigate(['detailpage']);
// }

  toPageview(id:string){
     this.router.navigate(['pageview',id]);
  }

}
